package com.zbs.framework.dao.rolefunction.service.model;

import com.zbs.framework.common.tree.TreeNode;
import com.zbs.framework.dao.function.entity.Function;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.util.List;

/**
 * 用户功能信息
 */
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
public class UserFunctionInfo implements TreeNode<Long> {

    private Long id;
    /**
     * 标识符
     */
    private String identifier;
    /**
     * 功能名
     */
    private String name;

    /**
     * 父级ID
     */
    private Long parentId;


    private List<?> children;

    public UserFunctionInfo(Long id, String identifier, String name) {
        this.id = id;
        this.identifier = identifier;
        this.name = name;
    }

    @Override
    public Long id() {
        return this.id;
    }

    @Override
    public Long parentId() {
        return this.parentId;
    }

    @Override
    public boolean root() {
        return this.parentId == null;
    }

    @Override
    public void setChildren(List<?> children) {
        this.children = children;
    }

    @Override
    public List<?> getChildren() {
        return this.children;
    }

    public UserFunctionInfo(Function function){
        this.id = function.getId();
        this.identifier = function.getIdentifier();
        this.name = function.getName();
        this.parentId = function.getParentId();
    }
}
